package g2.routemaster.bundle.gui;

import g2.routemaster.model.GameManager;
import g2.routemaster.model.ModelAdaptor;

import org.osgi.util.tracker.ServiceTracker;

public class GuiAdaptorImpl implements GuiAdaptor {

	private final ServiceTracker finderTrack;

	public GuiAdaptorImpl(ServiceTracker finderTrack) {
		this.finderTrack = finderTrack;
	}

   public GameManager getGameManager(){
      ModelAdaptor finder = (ModelAdaptor) finderTrack.getService();
      if (finder == null) {
         throw new RuntimeException("No service availible!");
      } else {
         return finder.getGameManager();
      }
   }
   
   public void setGameManager(GameManager gameManager){
      ModelAdaptor finder = (ModelAdaptor) finderTrack.getService();
      if (finder == null) {
         throw new RuntimeException("No service availible!");
      } else {
         finder.setGameManager(gameManager);
      }
   }

}
